/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.swt.mto.thithu.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import com.swt.mto.thithu.model.LoadAjax;
import com.swt.mto.thithu.model.LoadAjaxModel;

import java.io.Serializable;

import java.sql.Types;

import java.util.HashMap;
import java.util.Map;

/**
 * The base model implementation for the LoadAjax service. Represents a row in the &quot;mto_thithu_LoadAjax&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.swt.mto.thithu.model.LoadAjaxModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link LoadAjaxImpl}.
 * </p>
 *
 * @author tuan.nguyen
 * @see LoadAjaxImpl
 * @see com.swt.mto.thithu.model.LoadAjax
 * @see com.swt.mto.thithu.model.LoadAjaxModel
 * @generated
 */
public class LoadAjaxModelImpl extends BaseModelImpl<LoadAjax>
	implements LoadAjaxModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a load ajax model instance should use the {@link com.swt.mto.thithu.model.LoadAjax} interface instead.
	 */
	public static final String TABLE_NAME = "mto_thithu_LoadAjax";
	public static final Object[][] TABLE_COLUMNS = {
			{ "loadAjaxId", Types.BIGINT },
			{ "loadWeb", Types.VARCHAR },
			{ "ajax", Types.VARCHAR },
			{ "primaryAnswer", Types.BIGINT }
		};
	public static final String TABLE_SQL_CREATE = "create table mto_thithu_LoadAjax (loadAjaxId LONG not null primary key,loadWeb TEXT null,ajax VARCHAR(75) null,primaryAnswer LONG)";
	public static final String TABLE_SQL_DROP = "drop table mto_thithu_LoadAjax";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.swt.mto.thithu.model.LoadAjax"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.swt.mto.thithu.model.LoadAjax"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = false;
	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.swt.mto.thithu.model.LoadAjax"));

	public LoadAjaxModelImpl() {
	}

	public long getPrimaryKey() {
		return _loadAjaxId;
	}

	public void setPrimaryKey(long primaryKey) {
		setLoadAjaxId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_loadAjaxId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return LoadAjax.class;
	}

	public String getModelClassName() {
		return LoadAjax.class.getName();
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("loadAjaxId", getLoadAjaxId());
		attributes.put("loadWeb", getLoadWeb());
		attributes.put("ajax", getAjax());
		attributes.put("primaryAnswer", getPrimaryAnswer());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		Long loadAjaxId = (Long)attributes.get("loadAjaxId");

		if (loadAjaxId != null) {
			setLoadAjaxId(loadAjaxId);
		}

		String loadWeb = (String)attributes.get("loadWeb");

		if (loadWeb != null) {
			setLoadWeb(loadWeb);
		}

		String ajax = (String)attributes.get("ajax");

		if (ajax != null) {
			setAjax(ajax);
		}

		Long primaryAnswer = (Long)attributes.get("primaryAnswer");

		if (primaryAnswer != null) {
			setPrimaryAnswer(primaryAnswer);
		}
	}

	public long getLoadAjaxId() {
		return _loadAjaxId;
	}

	public void setLoadAjaxId(long loadAjaxId) {
		_loadAjaxId = loadAjaxId;
	}

	public String getLoadWeb() {
		if (_loadWeb == null) {
			return StringPool.BLANK;
		}
		else {
			return _loadWeb;
		}
	}

	public void setLoadWeb(String loadWeb) {
		_loadWeb = loadWeb;
	}

	public String getAjax() {
		if (_ajax == null) {
			return StringPool.BLANK;
		}
		else {
			return _ajax;
		}
	}

	public void setAjax(String ajax) {
		_ajax = ajax;
	}

	public long getPrimaryAnswer() {
		return _primaryAnswer;
	}

	public void setPrimaryAnswer(long primaryAnswer) {
		_primaryAnswer = primaryAnswer;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
			LoadAjax.class.getName(), getPrimaryKey());
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		ExpandoBridge expandoBridge = getExpandoBridge();

		expandoBridge.setAttributes(serviceContext);
	}

	@Override
	public LoadAjax toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (LoadAjax)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public Object clone() {
		LoadAjaxImpl loadAjaxImpl = new LoadAjaxImpl();

		loadAjaxImpl.setLoadAjaxId(getLoadAjaxId());
		loadAjaxImpl.setLoadWeb(getLoadWeb());
		loadAjaxImpl.setAjax(getAjax());
		loadAjaxImpl.setPrimaryAnswer(getPrimaryAnswer());

		loadAjaxImpl.resetOriginalValues();

		return loadAjaxImpl;
	}

	public int compareTo(LoadAjax loadAjax) {
		long primaryKey = loadAjax.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		LoadAjax loadAjax = null;

		try {
			loadAjax = (LoadAjax)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = loadAjax.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
	}

	@Override
	public CacheModel<LoadAjax> toCacheModel() {
		LoadAjaxCacheModel loadAjaxCacheModel = new LoadAjaxCacheModel();

		loadAjaxCacheModel.loadAjaxId = getLoadAjaxId();

		loadAjaxCacheModel.loadWeb = getLoadWeb();

		String loadWeb = loadAjaxCacheModel.loadWeb;

		if ((loadWeb != null) && (loadWeb.length() == 0)) {
			loadAjaxCacheModel.loadWeb = null;
		}

		loadAjaxCacheModel.ajax = getAjax();

		String ajax = loadAjaxCacheModel.ajax;

		if ((ajax != null) && (ajax.length() == 0)) {
			loadAjaxCacheModel.ajax = null;
		}

		loadAjaxCacheModel.primaryAnswer = getPrimaryAnswer();

		return loadAjaxCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(9);

		sb.append("{loadAjaxId=");
		sb.append(getLoadAjaxId());
		sb.append(", loadWeb=");
		sb.append(getLoadWeb());
		sb.append(", ajax=");
		sb.append(getAjax());
		sb.append(", primaryAnswer=");
		sb.append(getPrimaryAnswer());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(16);

		sb.append("<model><model-name>");
		sb.append("com.swt.mto.thithu.model.LoadAjax");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>loadAjaxId</column-name><column-value><![CDATA[");
		sb.append(getLoadAjaxId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>loadWeb</column-name><column-value><![CDATA[");
		sb.append(getLoadWeb());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>ajax</column-name><column-value><![CDATA[");
		sb.append(getAjax());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>primaryAnswer</column-name><column-value><![CDATA[");
		sb.append(getPrimaryAnswer());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = LoadAjax.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			LoadAjax.class
		};
	private long _loadAjaxId;
	private String _loadWeb;
	private String _ajax;
	private long _primaryAnswer;
	private LoadAjax _escapedModelProxy;
}